package com.bigflexlib.x.flash.geom
{
	
	
	import com.bigflexlib.utils.BasicTestBase;
	
	import flash.geom.Point;
	
	import mx.utils.StringUtil;


	public class GeomTestBase extends BasicTestBase
	{
		
		
		protected static function assertPointsEqual( point1:Point, point2:Point ):void
		{
			
			if ( ! point1.equals( point2 ) )
			{
				fail( 
					StringUtil.substitute( "Expected two equal points: p1:{0} != p2:{1} ", point1, point2 ) 
					);			
			}
		
		}
		
		
		
		/**
		 * 
		 * When working with trigonometric calculations, matrices, etc it is often the case where
		 * two points that should be equal take different values due to FP limitations and such.
		 * 
		 * This allows comparison considering a margin of error
		 * 
		 * @param point1
		 * @param point2
		 * @param maxDistance
		 * 
		 */		
		protected static function assertPointsSimilar( point1:Point, point2:Point, maxDistance:Number = 0.1 ):void
		{

			if ( Point.distance( point1, point2 ) > maxDistance )
			{
				fail( 
					StringUtil.substitute( "Expected two similar points: p1:{0} != p2:{1} ", point1, point2 ) 
					);	
			}

		}
			
		
		
	}

}